(c) Veronica Helms

Date: December 2016

Program Functions: Ingest AHS Data

Specify AHS Variables pulled by RELATIONAL TABLE:

  • TABLE: tTypec
    • COUNTY
  • TABLE: tNewHouse
    • BIGP
    • BUILD

In [66]:
# Import Dependencies #
import openpyxl
import pandas as pd
import os 
import csv

In [38]:
# Pull in Relational Table: tTypec #
df_type = os.path.join(os.getcwd(),'/Users/veronicahelms/Desktop/Untitled Folder/AHS/tTypec.csv')
print df_type


/Users/veronicahelms/Desktop/Untitled Folder/AHS/tTypec.csv

In [64]:
data_csv_type = pd.read_csv(df_type, index_col=None)
list(data_csv_type.columns.values)


Out[64]:
['CONTROL',
 'NOINT',
 'YRINTRO',
 'NATLFLAG',
 'BUILT',
 'PWT',
 'YRTYPEC',
 'CONTROLM',
 'OLDMSFLG',
 'SMSA']

In [65]:
#data_csv_type [['BUILT','CONTROL','CONTROLM']]
data_csv_type.head(5)


Out[65]:
CONTROL NOINT YRINTRO NATLFLAG BUILT PWT YRTYPEC CONTROLM OLDMSFLG SMSA
0 '052000000001' 37 '1996' '2' -6 483.9699 '1996' '000000000001' '-6' '0520'
1 '052000000003' 37 '1996' '2' -6 483.9699 '1996' '000000000003' '-6' '0520'
2 '052000000007' 37 '1996' '2' -6 483.9699 '1996' '000000000007' '-6' '0520'
3 '052000000012' 41 '1996' '2' 1990 483.9699 '2007' '000000000012' '-6' '0520'
4 '052000000014' 41 '1996' '2' 1996 483.9699 '2011' '000000000014' '-6' '0520'

In [41]:
# Pull in Relational Table: tNewHouse #
df_newhouse = os.path.join(os.getcwd(),'/Users/veronicahelms/Desktop/Untitled Folder/AHS/tnewhouse.csv')
print df_newhouse


/Users/veronicahelms/Desktop/Untitled Folder/AHS/tnewhouse.csv

In [71]:
data_csv_newhouse = pd.read_csv(df_newhouse, index_col=None)
list(data_csv_newhouse.columns.values)
data_csv_newhouse.head(5)


Out[71]:
CONTROL DEGREE METRO3 REGION SMSA LMED LMEDA LMEDB FMR FMRA ... HUDADMIN HUDSAMP ISTATUS AMTI CAMF FLRENT FMHOTF LRENT MHOTFE JBILLW
0 '036000001146' '4' '2' '4' '0360' 84200 84200 84200 2580 2580 ... '-6' '2' '1' 1600 12 -6 -6 -6 -6 '1'
1 '036000001147' '4' '2' '4' '0360' 84200 84200 84200 2241 2241 ... '-6' '2' '1' 1650 12 -6 -6 -6 -6 '1'
2 '036000001148' '4' '2' '4' '0360' 84200 84200 84200 1327 1327 ... '4' '2' '4' -6 -6 -6 -6 -6 -6 '-9'
3 '036000001149' '4' '2' '4' '0360' 84200 84200 84200 2577 2577 ... '-6' '2' '1' 2160 -7 -6 -6 -6 -6 '1'
4 '036000001150' '4' '2' '4' '0360' 84200 84200 84200 2241 2241 ... '-6' '2' '1' 900 12 -6 -6 -6 -6 '1'

5 rows × 909 columns